/*
 * 类名称:FireExtinguisherServiceImpl.java
 * 包名称:com.platform.service.impl
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2019-09-25 19:51:14        hww     初版做成
 *
 * Copyright (c) 2019-2019 微同科技
 */
package com.platform.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.utils.QueryPlus;
import com.platform.dao.FireExtinguisherDao;
import com.platform.entity.FireExtinguisherEntity;
import com.platform.service.FireExtinguisherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

/**
 * 灭火器Service实现类
 *
 * @author hww
 * @date 2019-09-25 19:51:14
 */
@Service("fireExtinguisherService")
public class FireExtinguisherServiceImpl extends ServiceImpl<FireExtinguisherDao, FireExtinguisherEntity> implements FireExtinguisherService {

    @Autowired
    private FireExtinguisherDao fireExtinguisherDao;

    @Override
    public List<FireExtinguisherEntity> queryAll(Map<String, Object> params) {
        return baseMapper.queryAll(params);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.id");
        params.put("asc", false);
        Page<FireExtinguisherEntity> page = new QueryPlus<FireExtinguisherEntity>(params).getPage();
        return page.setRecords(baseMapper.selectFireExtinguisherPage(page, params));
    }

    @Override
    public boolean add(FireExtinguisherEntity fireExtinguisher) {
        fireExtinguisher.setCreateTime(new Date());
        fireExtinguisher.setCreateUserId("");
        fireExtinguisher.setCreateUserName("黄伟伟");
        fireExtinguisher.setId(UUID.randomUUID().toString());
        return this.save(fireExtinguisher);
    }

    @Override
    public boolean update(FireExtinguisherEntity fireExtinguisher) {
        return this.updateById(fireExtinguisher);
    }

    @Override
    public boolean delete(String id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(String[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }
}
